package org.example.test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class IOtest {
    public static void main(String[] args) throws IOException {
     //1.创建对象并关联本地文件
        File file = new File("src\\main\\resources\\temp.txt");
        //创建只读模式
        boolean flag =file.setReadOnly();
     // FileReader frd = new FileReader("src\\main\\resources\\temp.txt");
        FileReader frd = new FileReader(file);

//2.读取数据 read()
        int ch;
        while ((ch = frd.read()) != -1) {
            //默认显示的是十进制数据，查看中文需要进行char强转
            System.out.print((char)ch);
        }
//3.释放资源
        frd.close();
        while (true){
            Scanner scanner = new Scanner(System.in);
            String s = scanner.next();
            System.out.println(s);
        }
    }
}
